{% extends "default/admin/include/innerBase.html" %}{% block script %}
<script src="/static/dialog/lhgdialog.min.js?self=true" type="text/javascript"></script>
<script src="/static/{{site.theme}}/js/utilitydlg.js" type="text/javascript"></script>
{% endblock %}{% block mainer %}
<div style="font-weight: bold; color:#FF0000;">缩略图没有可以不选择</div>
<table width="90%" id="picsList" class="elementList">
	<thead><tr>
    	<th width="100px"><div>类型</div></th><th width="100px"><div>名称</div></th><th width="100px"><div>链接地址</div></th>
    	<th width="80px"><div>缩略图</div></th><th width="120px"><div>图片</div></th><th width="100px"><div>描述</div></th><th width="50px"><div>显示</div></th><th><div>操作</div></th>
    </tr></thead>
	{% for e in imagesList %}{% include site.theme|stringformat:"s/admin/include/element.html" with e=e etype='images' %}{% endfor %}
	<tr id="addElement" class="treetr"><td colspan="9"><span class="addtree"><a href="javascript:addElement();">添加图片</a></span></td></tr>
</table>
<div id="addtb" style="display:none;"><form><table class="formTable">{{imagesForm}}</table></form></div>
<script type="text/javascript">
<!-- 
var addDlg = null, editDlg = null;
function addElement(){
	addDlg = $.dialog({
		id:'addDlg', title:'添加图片',
		content: $('#addtb').html(),
		max: false, min: false, lock: true,
		width: '410px',
		init: function(){
			$('#id_thumbnail').after("<a href='javascript:openImgDlg(\"id_thumbnail\",null);'>选择图片</a>   <a href='javascript:clearImg(\"id_thumbnail\",null);'>清空</a>");
			$('#id_image').after("<a href='javascript:openImgDlg(\"id_image\",null);'>选择图片</a>   <a href='javascript:clearImg(\"id_image\",null);'>清空</a>");
			$('#id_thumbnail').attr('readonly','readonly');
			$('#id_image').attr('readonly','readonly');
			bindPreImg('id_image', null);
			bindPreImg('id_thumbnail', null);
		},
		okVal: '增加',
	    ok: function(){
	    	var thisDlg = this;
	    	$.post('/picsAddImage.do', $('form',thisDlg.DOM.content).serialize()+"&_retType=json", 
    			function(data){
	    		if(data.flag){$.dialog.alert(data.msg, function(){thisDlg.close();thisDlg.reload();});}
     				else{$.dialog.alert(data.msg);}
      			},'json');
	    	return false;
	    },
	    cancel: true
	});
}
function editElement(id){
	var url = 'url:/picsDetailImage-'+id+'.html';
	editDlg = $.dialog({
		id:'editDlg', title:'编辑图片',
		content: url,
		max: false, min: false, lock: true,
		width: '410px',
		init: function(){
			$('#id_thumbnail', this.iwin.document.body).after("<a href='javascript:parent.openImgDlg(\"id_thumbnail\",parent.editDlg);'>选择图片</a>   <a href='javascript:parent.clearImg(\"id_thumbnail\",parent.editDlg);'>清空</a>");
			$('#id_image', this.iwin.document.body).after("<a href='javascript:parent.openImgDlg(\"id_image\",parent.editDlg);'>选择图片</a>   <a href='javascript:parent.clearImg(\"id_image\",parent.editDlg);'>清空</a>");
			$('#id_thumbnail', this.iwin.document.body).attr('readonly','readonly');
			$('#id_image', this.iwin.document.body).attr('readonly','readonly');
			bindPreImg('id_image', editDlg);
			bindPreImg('id_thumbnail', editDlg);
		},
		okVal: '编辑',
	    ok: function(){
	    	var thisDlg = this;
	    	var forms = $('form', thisDlg.iwin.document.body).serialize()+"&_retType=json";
	    	$.post('/picsEditImage.do', forms, 
    			function(data){
      				if(data.flag){$.dialog.alert(data.msg, function(){thisDlg.close();thisDlg.reload();});}
      				else{$.dialog.alert(data.msg);}
      			},'json');
	    	return false;
	    },
	    cancel: true
	});
}
function picsDelete(id){
	$("#e-"+id).attr('bgcolor','red');
	$.dialog.confirm('确定要删除此项么?',
			function(){
				var url="/picsDeleteImage-"+id+".do";
				$.post(url, {_retType:"json"},function (data){
							if(data.flag){$("#e-"+id).attr('bgcolor','red').fadeOut("slow",function(){$(this).remove();});}
							else $.dialog.alert(data.msg, function(){$("#e-"+id).removeAttr('bgcolor');});
				},'json');
			},
			function(){$("#e-"+id).removeAttr('bgcolor');}
	);
}
$(function(){listHover();});
//-->
</script>
{% endblock %}